package com.epoint.mobileoa.tools;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;

public class GetSysDate {

	// @SuppressWarnings("static-access")
	// public static String getDateFileName() {
	// // 获取系统时间，并格式化
	// Calendar calendar = Calendar.getInstance();
	// calendar.setTime(new Date());
	// int year = calendar.get(Calendar.YEAR);
	// int mounth = calendar.get(Calendar.MONTH) + 1;
	// int day = calendar.get(Calendar.DATE);
	// int hour = calendar.get(Calendar.HOUR_OF_DAY);// 24小时制
	// // int hour = calendar.get(Calendar.HOUR);12小时制
	// int min = calendar.get(calendar.MINUTE);
	// int secound = calendar.get(calendar.SECOND);
	// // 格式一：2011-11-1 12-12-66 作为文件名
	// String formateDate1 = String.valueOf(year) + "-" + AddZero(mounth)
	// + "-" + AddZero(day) + "  " + AddZero(hour) + "-"
	// + AddZero(min) + "-" + AddZero(secound);
	// return formateDate1;
	// }

	public static String AddZero(int i) {
		if (i >= 0 && i <= 9) {
			return "0" + i;
		}
		return String.valueOf(i);

	}

	@SuppressWarnings("static-access")
	public static String getFormateDate() {
		// 获取系统时间，并格式化
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		int year = calendar.get(Calendar.YEAR);
		int mounth = calendar.get(Calendar.MONTH) + 1;
		int day = calendar.get(Calendar.DATE);
		int hour = calendar.get(Calendar.HOUR_OF_DAY);
		int min = calendar.get(calendar.MINUTE);
		int secound = calendar.get(calendar.SECOND);
		String a[] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" };
		Random random = new Random();
		int i = random.nextInt(10);
		String extra = a[i];

		String mima = MiMa.jiami(extra + AddZero(min) + AddZero(secound)
				+ random.nextInt(10), 6);
		// 格式一：2011-11-1 12-12-66 作为图片文件名
		String formateDate1 = String.valueOf(year) + "-" + AddZero(mounth)
				+ "-" + AddZero(day) + " " + AddZero(hour) + "-" + AddZero(min)
				+ "-" + AddZero(secound) + " " + mima;
		// 格式二：2011年11月1日 12时12分45秒 写在照片上
		String formateDate2 = String.valueOf(year) + "年" + AddZero(mounth)
				+ "月" + AddZero(day) + "日  " + AddZero(hour) + "时"
				+ AddZero(min) + "分" + AddZero(secound) + "秒";
		// 格式一：2011-11-1 12-12-66 作为录音文件名
		String formateDate3 = String.valueOf(year) + "-" + AddZero(mounth)
				+ "-" + AddZero(day) + " " + AddZero(hour) + "-" + AddZero(min)
				+ "-" + AddZero(secound) + " ";
		return formateDate1 + ";" + formateDate2 + ";" + formateDate3;
	}

	// 获得格式化的日期
	public static String getFormateDate2() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HHmmss");
		return sdf.format(new Date());
	}

}
